﻿Public Class FormMain
    Dim objJlMst As New clsJlMst
    Dim objUser As New clsUser
    Private Sub FormMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        connectDB()
        getUserListByCJ()
        initData()
    End Sub

    Private Sub connectDB()
        g_szInitFileName = My.Application.Info.DirectoryPath & "\Client_Warehouse_JL.ini"

        g_Server.szDrive = GetIniFile("SERVER", "DRIVE", "PostgreSQL ANSI", g_szInitFileName)
        g_Server.szIPadr = GetIniFile("SERVER", "IP", "", g_szInitFileName)
        g_Server.szDbn = GetIniFile("SERVER", "DBN", "ZHENANSF", g_szInitFileName)
        g_Server.szUid = GetIniFile("SERVER", "UID", "sa", g_szInitFileName)
        g_Server.szPas = GetIniFile("SERVER", "PAS", "sa", g_szInitFileName)
        g_Server.iOver = CInt(GetIniFile("SERVER", "OVER", "-1", g_szInitFileName))

        If False = g_fDBconnect And 0 = g_iDBconnResult Then
            If "" = g_Server.szIPadr Or "0.0.0.0" = g_Server.szIPadr Then
            Else
                g_fDBconnect = True

                'データベース接続
                With g_Server
                    g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDbn, .szUid, .szPas, .iOver)
                    If 1 <> g_iDBconnResult Then
                        .szDrive = CStr(IIf("PostgreSQL" = .szDrive, "PostgreSQL ANSI", "PostgreSQL"))
                        g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDbn, .szUid, .szPas, .iOver)
                    End If
                End With
            End If
        End If

    End Sub

    Private Sub getUserListByCJ()
        Dim dtUser As DataTable = objUser.getUserListByCJ(2)
        cmbOper.DisplayMember = "user_name"
        cmbOper.ValueMember = "user_id"
        cmbOper.DataSource = dtUser
    End Sub

    Public Sub initData()
        Dim dt As DataTable = objJlMst.getAllList(String.Empty)
        dt.Columns.Add("validity_name")
        For Each row As DataRow In dt.Rows
            If row("validity") = "0" Then
                row("validity_name") = "无效"
            Else
                row("validity_name") = "有效"
            End If
        Next
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dt
    End Sub

    Private Sub btnInto_Click(sender As Object, e As EventArgs) Handles btnInto.Click
        Dim frmInto As New FormInto()
        frmInto.usr = cmbOper.Text.Trim()
        frmInto.ShowDialog(Me)
    End Sub

    Private Sub btnIntoRecord_Click(sender As Object, e As EventArgs) Handles btnIntoRecord.Click
        Dim frmInto As New FormIntoRecord()
        frmInto.ShowDialog(Me)
    End Sub

    Private Sub btnOut_Click(sender As Object, e As EventArgs) Handles btnOut.Click
        Dim frmOut As New FormOut()
        frmOut.usr = cmbOper.Text.Trim()
        frmOut.ShowDialog(Me)
    End Sub

    Private Sub btnOutRecord_Click(sender As Object, e As EventArgs) Handles btnOutRecord.Click
        Dim frmOut As New FormOutRecord()
        frmOut.ShowDialog(Me)
    End Sub

    Private Sub FormMain_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        DBacs.Disconnect()
    End Sub

End Class
Public Class entityjl_rk
    Public factory_id As String   ' 工厂ID
    Public batch_no As String   ' 批次
    Public location As String   ' 库位号
    Public pgd_id As String   ' 派工单号
    Public production_date As DateTime   ' 抛丸时间
    Public into_date As DateTime   ' 入库时间
    Public end_date As DateTime   ' 出库时间
    Public into_weight As Decimal   ' 入库重量
    Public assist_marker As String  '外协厂家
    Public update_time As String   ' 修改时间
    Public into_ope As String '入库作业员
    Public mst_value As String '
    Public validity As String '
End Class